package cn.itlaobing.dao;

import cn.itlaobing.entity.TrainEntity;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.dbutils.ResultSetHandler;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Map;

/**
 * Created by kevin on 2017/11/10.
 */
public class TrainResultHangler implements ResultSetHandler<Map<String,Object>> {

    @Override
    public Map<String,Object> handle(ResultSet rs) throws SQLException {
        Map<String,Object> map=new HashedMap();
        if (rs.next()){
            map.put("trainNum",rs.getString("trainNum"));
            map.put("startStation",rs.getString("startStation"));
            map.put("endStation",rs.getString("endStation"));
            map.put("price",rs.getFloat("price"));
            return map;
        }
        return null;
    }
}
